package com.linkai.blibli2021.blibli3;

import java.util.*;

class Solution {
    /* Write Code Here */
    public int check(String input, int rule_cnt, String rules) {

        // 1. 首先对字符串进行处理
        // 1.1 去除首尾分号
        char[] charsInput = input.toCharArray();
        String inputStr = String.valueOf(charsInput, 1, charsInput.length - 2);
        String[] inputSplit = inputStr.split(",");
        char[] charsRules = rules.toCharArray();
        String rulesStr = String.valueOf(charsRules, 1, charsRules.length - 2);
        String[] rulesSplit = rulesStr.split(",");

        // 在限定时间下发布动态的条数
        int num = 0;
        int time = 0;   // 上次解封之后到现在的持续时间
        boolean flag =false;        // 是否封禁的标识符
        int stopTime = 0;   // 当前已经封禁了多长时间
        int stopNum = 0;    // 封禁状态下被阻止的动态
        // 遍历发布序列
        for (int i = 0; i < inputSplit.length; i++) {
            // 如果账号被封禁
            if (flag && stopTime <= Integer.valueOf(rulesSplit[2])) {
                // 解封时间已经到达
                if (stopTime == Integer.valueOf(rulesSplit[2])) {
                    stopTime = 0;
                    num = 0;
                    time = 0;
                    flag = false;
                } else {
                    stopTime++;     // 封禁时间增加
                }
                if (inputSplit[i].equals("1")) {
                    stopNum++;
                }
                // 跳过后续操作
                continue;
            }

            if (inputSplit[i].equals("1")) {
                num++;
                time++;
            } else {
                time++;
            }
            // 每次都需要判断是否达到阈值
            if (time <= Integer.valueOf(rulesSplit[0])
                    && num == Integer.valueOf(rulesSplit[1])) {
                // 封禁
                flag = true;
            }
        }


        return stopNum;
    }
}

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        HashMap<String, String> map = new HashMap<>();
        int res;
            
        String _input;
        try {
            _input = in.nextLine();
        } catch (Exception e) {
            _input = null;
        }
        
        int _rule_cnt;
        _rule_cnt = Integer.parseInt(in.nextLine().trim());
        
        String _rules;
        try {
            _rules = in.nextLine();
        } catch (Exception e) {
            _rules = null;
        }
  
        res = new Solution().check(_input, _rule_cnt, _rules);
        System.out.println(String.valueOf(res));    

    }
}
